package com.paziy.notes.core;

/**
 * All octaves and methods for work with them.
 * Warning!!! Order of octaves can't be changed!!!
 *
 * @author thecederick@gmail.com (Paziy Evgeniy)
 * @version 0.3
 * @since 0.1 (27.11.13 11:38)
 */
public enum Octave {
    SubContra,
    Contra,
    Great,
    Small,
    OneLine,
    TwoLine,
    ThreeLine,
    FourLine,
    FiveLine,
    SixLine;

    /**
     * Class constant holds the smallest octave
     */
    public static final Octave SMALLEST = SubContra;

    /**
     * Class constant hold the highest octave
     */
    public static final Octave HIGHEST = SixLine;

    /**
     * Holds next octave from current
     */
    private Octave next;

    /**
     * Holds previous octave from current
     */
    private Octave previous;

    /**
     * Initialization of instance fields {next} and {previous}
     * @see com.paziy.notes.core.Octave#next
     * @see com.paziy.notes.core.Octave#previous
     */
    static {
        SubContra.next = Contra;
        SubContra.previous = null;

        Contra.next = Great;
        Contra.previous = SubContra;

        Great.next = Small;
        Great.previous = Contra;

        Small.next = OneLine;
        Small.previous = Great;

        OneLine.next = TwoLine;
        OneLine.previous = Small;

        TwoLine.next = ThreeLine;
        TwoLine.previous = OneLine;

        ThreeLine.next = FourLine;
        ThreeLine.previous = TwoLine;

        FourLine.next = FiveLine;
        FourLine.previous = ThreeLine;

        FiveLine.next = SixLine;
        FiveLine.previous = FourLine;

        SixLine.next = null;
        SixLine.previous = FiveLine;

    }


    /**
     * Number of octave in scientific notation
     *
     * @return index number of octave from 0 to 9
     */
    public int getNumber() {
        return this.ordinal();
    }

    /**
     * Getter for "next" field
     * @see com.paziy.notes.core.Octave#next
     *
     * @return next octave from current. Can be null if current octave is the highest.
     */
    public Octave getNextOctave() {
        return next;
    }

    /**
     * Getter for "previous" field
     * @see com.paziy.notes.core.Octave#previous
     *
     * @return previous octave from current. Can be null if current octave is the smallest.
     */
    public Octave gerPreviousOctave() {
        return previous;
    }
}
